import {
	MessageConstant
} from "zpub_http/constant/MessageConstant.js"
import {
	WhatConstant
} from "zpub_http/constant/WhatConstant.js"
import {
	HttpParamKeyValue
} from "zpub_svr/constant/HttpParamKeyValue.js"
import {
	HttpProtocol
} from "zpub_http/http/HttpProtocol.js"
import {
	BaseService
} from "zpub_http/service/BaseService.js"
import {
	MajorMinorBusiness
} from "../../constant/MajorMinorBusiness.js"
import {
	FldValueBusiness
} from "../../constant/FldValueBusiness.js"
import {
	MajorMinorConstant
} from "zpub_db/constant/MajorMinorConstant.js"

/*
 * 功能：公共服务模块
 * 需要传入的键：
 * 传入的值类型：
 * 传入的值含义：
 * 是否必传 ：
 * 作者：郑朝军 on 2019/4/7 23:23
 * 邮箱：1250393285@qq.com
 * 公司：武汉智博创享科技有限公司
 */
class CopyService extends BaseService {

	/*
	 * 查询属性<br/>
	 */
	static queryParcel(listener) {
		listener.showLoading({
			title: '正在查询***'
		});
		let protocol = new HttpProtocol();
		protocol
			.setService('SvrPubQueryControl')
			.setMethod('InitSvr')
			.addParam(HttpParamKeyValue.PARAM_KEY_CMD, HttpParamKeyValue.PARAM_VALUE_LOGIN)
			.addParam(HttpParamKeyValue.PARAM_KEY_MAJOR, "主类型")
			.addParam(HttpParamKeyValue.PARAM_KEY_MINOR, "子类型")
			.addParam("sys", "11")
			.post().then((data) => {
				let jo = this.responseData(data);
				if (this.isDataInvalid("queryParcel", jo, listener)) {
					return MessageConstant.MSG_EMPTY;
				}
				this.sendMessage("queryParcel", data, WhatConstant.WHAT_NET_DATA_SUCCESS, listener);
			})
			.catch((err) => {
				this.sendMessage("queryParcel", err, WhatConstant.WHAT_NET_DATA_FAIL, listener);
			});
	}

	/*
	 * 查询属性<br/>
	 */
	static queryByWin(_major, _minor, coor, listener, method) {
		listener.showLoading({
			title: '正在查询坐标'
		});
		let protocol = new HttpProtocol();
		protocol
			.setMethod(HttpParamKeyValue.PARAM_KEY_METHOD_AreaSvr)
			.addParam(HttpParamKeyValue.PARAM_KEY_CMD, HttpParamKeyValue.PARAM_VALUE_QueryByWin)
			.addParam(HttpParamKeyValue.PARAM_KEY_MAJOR, _major)
			.addParam(HttpParamKeyValue.PARAM_KEY_MINOR, _minor)
			.addParam('coor', coor)
			.post().then((data) => {
				if (this.isDataInvalid(TextUtil.isEmpty(method) ? "queryByWin" : method, data[0], listener)) {
					return MessageConstant.MSG_EMPTY;
				}
				this.sendMessage(TextUtil.isEmpty(method) ? "queryByWin" : method, data, WhatConstant.WHAT_NET_DATA_SUCCESS,
					listener);
			})
			.catch((err) => {
				this.sendMessage(TextUtil.isEmpty(method) ? "queryByWin" : method, err, WhatConstant.WHAT_NET_DATA_FAIL, listener);
			});
	}
}

export {
	CopyService
}
